package com.yumeno.epidemic.Controller;

import com.yumeno.epidemic.beans.AjaxRespInfo;
import com.yumeno.epidemic.beans.ProvinceInfo;
import com.yumeno.epidemic.service.ProvinceService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/province")
public class ProvinceController {
    private Logger logger = Logger.getLogger(ProvinceController.class);

    @Autowired
    private ProvinceService provinceService;


    @GetMapping("ajax/noDataList")
    @ResponseBody   //返回数据转化成Json格式
    public AjaxRespInfo noDataList(String date) {
        List<ProvinceInfo> list = null;
        AjaxRespInfo<List<ProvinceInfo>> respInfo= new AjaxRespInfo<>();
        if (!StringUtils.isEmpty(date)) {
            list = this.provinceService.findNoDataProvince(date);
            respInfo.setData(list);
            respInfo.setCode(0);
        } else {
            respInfo.setCode(-1);
            respInfo.setMsg("参数不足");
        }
        logger.debug("date=" + date);
        return respInfo;
    }

}
